<?php
/**
 *      [Jsen.net] (C)2013-2099 Jason Group Science and technology co., LTD.
 *      This is NOT a freeware, use is subject to license terms
 * 
 *      http://www.jsen.net
 *      tel:400-681-9511
 */
class UserMoneylogModel extends SystemModel {

    public function lists() {
    	$sqlmap = array();
    	if ($_GET['keyword']) {
    		$map = array();
    		$map['username|mobile_phone'] = array('LIKE',"%".trim($_GET['keyword'])."%");
    		$ids = model('user')->where($map)->getField('id',TRUE);
    		$sqlmap['user_id'] = array('IN',$ids);
    	}
		if($_GET["start"]!="" or $_GET["end"]!=""){
				$start = strtotime($_GET['start'].' 00:00:00');
				$end = strtotime($_GET['end'].' 23:59:59');
				$sqlmap['dateline'] =array('between',$start.','.$end);
		}
		if($_GET["type"]!=""){
			$sqlmap['type'] = array('eq',$_GET["type"]);
		}
		$money_type=C("MONEY_TYPE");
    	$infos = $this->where($sqlmap)->order('id DESC')->limit(($_GET['pagenum']-1)*$_GET['rowsnum'].','.$_GET['rowsnum'])->select();
    	foreach ($infos as $k => $info) {

            $user = M("user")->field("username,mobile_phone,user_type,true_name")->find($info['user_id']);
            $info['username'] = $user['username'];
            $info['true_name'] = $user['true_name'];
            $info['mobile_phone'] = $user['mobile_phone'];
    		$info['user_type'] = "V".$user['user_type'];

			$info['type'] = $money_type[$info["type"]];
    		$infos[$k] = $info;


    	}
    	return $infos;
    }
}

